package com.lyz.dataStructure.algorithm.pinduoduo2019;

import java.util.Arrays;
import java.util.Scanner;

/**
 *@Author:759057893@qq.com Lyz
 *@Date: 2019/7/27 12:09
 *@Description:
 **/
public class Main1{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for(int i =0;i<n;i++){
            arr[i] = sc.nextInt();
        }
        System.out.println(Maxshu(arr));
    }

    public static int Maxshu(int[] arr){
         if(arr==null||arr.length==0){
             return 0;
         }
         int num =0;
         int maxshu = 1;
         int i =0;
         for(;i<arr.length-1;i++){
             for(int j =0;j<arr.length-1-i;j++){
                 if(arr[j]>arr[j+1]){
                     num = arr[j+1];
                     arr[j+1] =arr[j];
                     arr[j] =num;
                 }

             }
             System.out.println(Arrays.toString(arr));
         }
         maxshu  = arr[arr.length-1]*arr[arr.length-2]*arr[arr.length-3];
         return  maxshu;
    }
}
